Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 4x 4x 4x 3x 3x 3x 1x 1x 1x | import { NextRequest, NextResponse } from "next/server";
import { requireAuth } from "@/lib/auth";
import { InvitationController } from "@/server/api/invitations";
import { requireApiInvitationCapability } from "@/server/dal/collection-access";
import { getDb } from "@/lib/db";
import { errorResponse } from "@/server/api/http-errors";
export async function POST(
_request: NextRequest,
{ params }: { params: Promise<{ id: string }> }
) {
try {
const { id } = await params;
const user = await requireAuth();
const db = getDb();
// invitations:manage = owner — tightens from member-or-owner (PR1) to owner-only.
const invitation = await requireApiInvitationCapability(db, id, user.id, "invitations:manage");
if (invitation instanceof NextResponse) return invitation;
const result = await InvitationController.fromDb(db).resendInvitation(id);
return NextResponse.json(result);
} catch (error) {
return errorResponse(error);
}
}
|